import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		userinfo: {
			jscode: '',
			token: '',
			user_id: '',
			info: {
				nickName: ''
			}
		}
	},
	mutations: {
		userlogin(state, provider) {
			state.userinfo = provider
			uni.setStorage({
				key: 'userinfo',
				data: provider
			})
		},
		userlogout(state) {
			state.userinfo = {}
			uni.removeStorage({
				key: 'userinfo'
			})
		}
	},

})

export default store
